package com.zzyy.study.controller;

import com.zzyy.study.entities.Customer;
import com.zzyy.study.resp.ResultData;
import com.zzyy.study.service.CustomerService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @auther zzyy
 * @create 2024-01-20 18:20
 */
@RestController
@Slf4j
public class CustomerController
{
    @Resource
    private CustomerService customerService;

    @PostMapping(value = "/customer/add")
    public int add(@RequestBody Customer customer)
    {
        return customerService.add(customer);
    }

    @GetMapping(value = "/customer/get/{id}")
    public ResultData<Customer> getCustomerById(@PathVariable("id") Integer id)
    {
        Customer result = customerService.getCustomerById(id);

        return ResultData.success(result);

    }
}
